package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.MedicalPolicyMapper;
import com.example.houduan.Pojo.MedicalPolicy;
import com.example.houduan.Service.MedicalPolicyService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MedicalPolicyServiceImpl implements MedicalPolicyService {

    @Autowired
    MedicalPolicyMapper medicalPolicyMapper;

    @Override
    public PageModel getMedicalPolicyPage(int num, int size) {
        int count =medicalPolicyMapper.selectMedicalPolicyCount();
        PageModel pm = new PageModel(num,count,size);
        pm.setList(medicalPolicyMapper.selectMedicalPolicyLimit((num-1)*size,size));
        return pm;
    }

    @Override
    public int deleteMedicalPolicy(Integer medicalpolicy_id) {
        return medicalPolicyMapper.deleteMedicalPolicy(medicalpolicy_id);
    }

    @Override
    public int updateMedicalPolicy(MedicalPolicy medicalPolicy) {
        return medicalPolicyMapper.updateMedicalPolicy(medicalPolicy);
    }

    @Override
    public int addMedicalPolicy(MedicalPolicy medicalPolicy) {
        return medicalPolicyMapper.insertMedicalPolicy(medicalPolicy);
    }

    @Override
    public List<MedicalPolicy> getAllMedicalPolicy() {
        return medicalPolicyMapper.selectAllMedicalPolicy();
    }
}
